package demo.controller;

import demo.Result;
import demo.dto.RequestWithLongDto;
import demo.entity.Company;
import demo.service.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class CompanyController {
    @Autowired
    CompanyService companyService;

    @PostMapping("/listCompanies")
    public Result listCompanies() {
        List<Company> companies = companyService.listCompanies();
        return Result.success("公司查询成功", companies);
    }

    @PostMapping("/getCompanyData")
    public Result getCompanyData(@Validated @RequestBody RequestWithLongDto requestWithLongDto) {
        return companyService.find(requestWithLongDto.getId());
    }
}
